<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>表单验证 </title>
<style>
.has-error{
	color: #f00;
	border-bottom: 1px solid #f00;
}

.all-error{
	background: #ffeba9;
	border: 3px solid #f00;
	padding: 8px;
	margin: 16px;
}
</style>
</head>
<body>
	<h2>表单验证 - JSR303 @Valid 例子 - Spring 接口实现</h2>

	<form:form method="POST" commandName="user" action="/valid/cus/post">
		<form:errors path="*" element="div" cssClass="all-error"/>
		<table>
			<tr>
				<td>编号 :</td>
				<td><form:input path="id" /></td>
				<td><form:errors path="id" cssClass="has-error"/></td>
				<td>不能为空</td>
			</tr>
			<tr>
				<td>姓名 :</td>
				<td><form:input path="name" /></td>
				<td><form:errors path="name" cssClass="has-error"/></td>
				<td>必须填写, 长度限制在3~20之间</td>
			</tr>
			<tr>
				<td>年龄 :</td>
				<td><form:input path="age" /></td>
				<td><form:errors path="age" cssClass="has-error"/></td>
				<td>必须填写, 大小限制在6~46之间</td>
			</tr>
			<tr>
				<td>地址 :</td>
				<td><form:input path="addr" /></td>
				<td><form:errors path="addr" cssClass="has-error"/></td>
				<td>必须填写, 长度必须超过4个字</td>
			</tr>
			<tr>
				<td colspan="3"><input type="submit" value="验证"/></td>
			</tr>
		</table>
	</form:form>

</body>
</html>